package com.bop.dehong.more;

import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;

import com.base.dehong.http.RequestCallBack;
import com.base.dehong.util.ToastUtils;
import com.bop.dehong.R;
import com.bop.dehong.base.BaseActivity;
import com.bop.dehong.base.DeHongApp;
import com.bop.dehong.base.TopManager;
import com.bop.dehong.http.model.FeedbackModel;
import com.bop.dehong.info.EmptyInfo;

/**
 * 意见反馈
 * @author TangWenhan/YeFengyun
 */
public class FeedbackActivity extends BaseActivity{

	private EditText mContentEt;
	private FeedbackModel feedbackModel;
	
	@Override
	protected void initTop() {
		View mView = getView(R.id.top);
		TopManager manager = new TopManager(mView);
		manager.setTitle(R.string.feedback);
		manager.setLeftImageVisibility(View.VISIBLE);
	}

	@Override
	protected void initUI() {
		mContentEt = getView(R.id.editText1);
		registerOnClickListener(getView(R.id.submit_btn));
	}

	@Override
	protected void initData() {
	}

	@Override
	protected int getContentViewId() {
		TAG = getClass().getName();
		return R.layout.act_feedback;
	}
	/**
	 * 提交
	 * @param v
	 */
	public void submit(){
		String contentStr = getStr4TextView(mContentEt);
		if (TextUtils.isEmpty(contentStr)) {
			ToastUtils.show(this, "请先写下您的意见或是建议！");
			return;
		}
		//提交
		showProgressDialog();
		if (feedbackModel == null) {
			feedbackModel = new FeedbackModel(this, callback);
		}
		feedbackModel.doNet(DeHongApp.mLoginEntity.getUid(), contentStr);
	}

	RequestCallBack<EmptyInfo> callback = new RequestCallBack<EmptyInfo>() {

		@Override
		public void end() {
			disappearProgressDialog();
		}
		
		public void onSuccess(EmptyInfo info) {
			ToastUtils.show(FeedbackActivity.this, "提交反馈成功！");
			finishCurrentActivity();
			super.onSuccess(info);
		};
		
	};

	@Override
	public void onClick(View v)
	{
		switch (v.getId()) {
		case R.id.submit_btn:
			submit();
			break;

		default:
			break;
		}
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id)
	{
		// TODO Auto-generated method stub
		
	}
	
}

